package org.gdstash.combobox;

import org.gdstash.ui.util.ComboBoxSearchPanel;
import org.gdstash.ui.util.WideMetalComboBoxUI;

import javax.swing.*;
import java.awt.*;
 
public class ComboBoxWithScrollBar {
    public static void main(String[] args) {
        JFrame frame = new JFrame("ComboBox with ScrollBar");

        DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<>();
        // 填充JComboBox以模拟较长列表
        for (int i = 0; i < 100; i++) {
            comboBoxModel.addElement("ItemItemItemItemItemItemItemItemItemItemItemItemItem " + i);
        }

        JComboBox<String> comboBoxSearchPanel = new JComboBox<>(comboBoxModel);
        comboBoxSearchPanel.setUI(new WideMetalComboBoxUI());
 
        // 将JScrollPane添加到JFrame的内容面板
        frame.getContentPane().add(comboBoxSearchPanel, BorderLayout.CENTER);
 
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}